package com.jk.controller;

import com.jk.bean.Page;
import com.jk.bean.SendPage;
import com.jk.service.MonthGuanZhuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Description: 骚骚的🐏
 * @Author: 杨
 * @Date: 2019/3/7 09:56
 */
@Controller
@RequestMapping("monthGuanZhu")
public class MonthGuanzhuController {
    @Autowired
    private MonthGuanZhuService monthGuanZhuService;
    @ResponseBody
    @RequestMapping("yue")
    public SendPage queryMonthGuanZhu(Page page){
        SendPage pag=  monthGuanZhuService.queryMonthGuanZhu(page);

        return pag;
    }
    @Scheduled(cron = "00 00 00 * * ?")
    public void timer(){
        //获取当前时间  localDateTime = 2019-03-07T18:48:10.007
        LocalDateTime localDateTime =LocalDateTime.now();
        System.out.println(localDateTime);
        if(localDateTime.format(DateTimeFormatter.ofPattern("dd HH:mm:ss")).equals("01 00:00:00")){
            System.out.println("当前时间为:" + localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            //修改月排行榜清零
            monthGuanZhuService.updateAuthorMonthattention();

        }else{
            System.out.println("123");

        }

    }

}
